package com.finance.rule.bean.pojo;

import com.finance.framework.lang.BaseObject;
import com.finance.system.bean.pojo.Organization;
import com.finance.system.bean.pojo.Supplier;
import com.finance.util.DateUtil;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 重量区间管理bean
 */
@Data
public class WeightRangeRule extends BaseObject {

    private SettlementRegion settlementRegion;
    private ValueRange valueRange;
    private String nickname;
    private String code;
    private Supplier supplier;
    private Organization organization;
    private Integer direction;
    private String snapshot;
    /**
     * 首重值
     */
    private String fixWeight;
    /**
     *首重单价 单位元
     * */
    private BigDecimal firstPrice;
    /**
     *续重单价 单位元
     * */
    private BigDecimal secondPrice;
    /**
     * 左边界数值
     */
    private String pointLeft;
    /**
     * 右边界数值
     */
    private String pointRight;
    /**
     *机构编码 表示此机构下配送员适配当前规则
     * */
    private String orgCode;

    private Integer cod;//是否含有待收款(1是0非)

    /**
     *启用时间 规则变化后不到指定时间不会直接生效
     * */
    private Date startTime;
    /**
     *关闭时间 新规则在指定时间关闭
     * */
    private Date endTime;

    private String supplierCodeImport;

    private String directionImport;

    private String regionImport;

    private String containLeftImport;

    private String containRightImport;

    private String codImport;

    @Override
    public boolean equals(Object object){
        if(object instanceof WeightRangeRule){
            WeightRangeRule role = (WeightRangeRule) object;
            return role.getId().compareTo(role.getId())==0;
        }
        return false;
    }
    @Override
    public int hashCode(){
        return this.getId().hashCode();
    }

    public String getStartTimeStr(){
        if(this.startTime==null){
            return null;
        }
        return DateUtil.dateFormat(this.startTime);
    }

    public String getEndTimeStr(){
        if(this.endTime==null){
            return null;
        }
        return DateUtil.dateFormat(this.endTime);
    }
}
